<template>
	<view>
		<!-- 关联列表 -->
		<view class="tabs">
			<view class="tabs-item" :class="{selected:index == active}" v-for="(item,index) in tabs" :key="item.value"
				@click="active =index">
				{{item.label}}
				<view v-if="index == active" class="tabs-item-bottom"></view>
			</view>
		</view>
		<view class="search">
			<input class="search-input" placeholder="请输入学生姓名" />
		</view>

		<view class="list">
			<view class="list-item" v-for="item in list">
				<view class="list-item-name">小夜曲</view>
				<image class="list-item-sex" src="/static/img/ic-sex-0.png"></image>
				<view class="list-item-phone">187567565785</view>
				<view class="list-item-class">3年二班</view>
				<view class="list-item-op">
					<view v-if="active==0" class="list-item-op-unbind">
						<image src="/static/img/ic-unbind.png"></image>解绑
					</view>
					<view v-if="active==0" class="list-item-op-edit" @click="openDialog">
						<image src="/static/img/ic-edit.png"></image>修改
					</view>
					<view v-if="active==1" class="list-item-op-bind">
						<image src="/static/img/ic-bind.png"></image>绑定
					</view>
				</view>
			</view>
		</view>
		<BindDialog ref="dialogRef" />
	</view>
</template>
<script>
	import BindDialog from './BindDialog.vue';
	export default {
		components: {BindDialog},
		data() {
			return {
				tabs: [{
					label: '已绑定',
					value: 0
				}, {
					label: '未绑定',
					value: 1
				}],
				active: 0,
				list: [{}]
			}
		},

		methods: {
			//绑定
			openDialog() {
				this.$refs.dialogRef.open();
			},
			//学生详情
			goDetail() {
				uni.navigateTo({
					url: '/pages/student/detail'
				})
			},
			//历史成绩
			goHistory() {
				uni.navigateTo({
					url: '/pages/student/history'
				})
			},
			//个人中心
			goMine() {
				uni.navigateTo({
					url: '/pages/mine/index'
				})
			},
			//消息通知
			goMsg() {
				uni.navigateTo({
					url: '/pages/msg/index'
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.search {
		margin-left: 40rpx;

		input {
			padding: 0 30rpx;
			width: 400rpx;
			height: 50rpx;
			border-radius: 25rpx;
			background: #fff;
		}
	}

	.tabs {
		margin: 20rpx 30rpx;
		display: flex;

		&-item {
			padding: 0 20rpx;
			color: #999;
			font-size: 32rpx;

			&.selected {
				color: #1A1A1A;
			}

			&-bottom {
				margin: auto;
				width: 28rpx;
				height: 6rpx;
				border-radius: 3rpx;
				background: #647FFB;
			}

		}
	}

	.list {
		margin-top: 20rpx;
		display: flex;
		flex-direction: column;
		align-items: center;

		&-item {
			width: 680rpx;
			border-radius: 20rpx;
			background: #FFFFFF;
			box-sizing: border-box;
			padding: 20rpx;
			margin-bottom: 20rpx;
			position: relative;

			&-op {
				position: absolute;
				right: 20rpx;
				top: 30rpx;
				display: flex;

				&-unbind {
					color: #0D9275;
					font-size: 28rpx;

					image {
						width: 28rpx;
						height: 28rpx;
					}
				}

				&-edit {
					margin-left: 20rpx;
					color: #0D9275;
					font-size: 28rpx;

					image {
						width: 28rpx;
						height: 28rpx;
					}
				}

				&-bind {
					color: #0D9275;
					font-size: 28rpx;

					image {
						width: 28rpx;
						height: 28rpx;
					}
				}
			}

			&-name {
				font-weight: bold;
				font-size: 32rpx;
				color: #1A1A1A;
			}

			&-sex {
				position: absolute;
				left: 180rpx;
				top: 26rpx;
				width: 32rpx;
				height: 32rpx;
			}

			&-phone {
				margin-top: 16rpx;
				font-size: 28rpx;
				color: #1A1A1A;
			}

			&-class {
				position: absolute;
				right: 20rpx;
				top: 72rpx;
				color: #666;
				font-size: 28rpx;
			}
		}
	}
</style>